﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using FIFP.DashBoard.Model;
using Telerik.Windows.Controls;
using Telerik.Windows.Controls.ScheduleView;

namespace FIFP.DashBoard.Converters
{
    public class OptimizationScheduleDragDropBehavior : ScheduleViewDragDropBehavior
    {
        public override bool CanDrop(DragDropState state)
        {
            Resource sourceResource = null;
            Resource destinationResource = null;

            Appointment ap = (Appointment)state.Appointment;
            FIFPAppointment appointment = (FIFPAppointment)state.Appointment;
            foreach (Resource resource in ap.Resources)
            {
                sourceResource = resource;
                break;
            }

            foreach (Slot s in state.DestinationSlots)
            {
                foreach (Resource resource in s.Resources)
                {
                    destinationResource = resource;
                    break;
                }
            }

            if (sourceResource == destinationResource && (appointment != null && !appointment.IsLinkedShutdownPlan && !appointment.IsSelectedLocationActivityLock))
                return true;
            else
                return false;
        }
       
        public override bool CanResize(DragDropState state)
        {
            FIFPAppointment appointment = (FIFPAppointment)state.Appointment;
            if (appointment != null && !appointment.IsLinkedShutdownPlan && !appointment.IsSelectedLocationActivityLock)
                return true;
            else
                return false;
        }
    }
}
